﻿
# DevScope BI PowerShell Samples
# 
# http://devscopebisamples.codeplex.com/
# http://www.devscope.net

write-host "---Outliers---"

Import-Module .\DevScope.BI.Samples.PowerShell.psm1 -Force

. .\execconfig.ps1      

$data = Invoke-OLEDBCommand -connectionString $connStr -sql "select * from XXXXXXXXXXXXXXXXXXXXXX "

$dmTable = Set-Outliers -dataTable $data[0].Table -connectionString $ssasconn

write-host "Evaluating OutlierProbability threshold..."
$x=$dmTable |  sort-object OutlierProbability -descending | select -index 5| select OutlierProbability 

write-host "Highlighting..."
$dmTable=$dmTable | select *,@{name="SysRowCssClass";expression={if ($_.OutlierProbability -ge $x.OutlierProbability ){ "highlight" } else { "" }}} | sort-object OutlierProbability -descending


$html=Out-Email -subject "Outliers Report" -sendConditionExpression {$_.OutlierProbability -ge $x.OutlierProbability } -inputObject $dmTable -to $mailto -from $mailfrom -smtpServer $mailsmtp


write-host "Done!"




 
 
 
 


